{% extends 'base.html' %}
{% block body %}
    {% ifequal user item.nickname %}
    <div class="item-edit">
        <a href="/post/{{ item.id }}">(edit)</a>
        -
        <a href="/post/{{ item.id }}/delete">(delete)</a>
    </div>
    {% endifequal %}
    <div class="item-title">{{ item.title }}</div>
    <div class="item-url">{{ item.url|urlize }}</div>
    <br>
    <br>
    <form class="comment-form" action="/comment/{{ item.id }}" method="post">
        <label>Comment</label><br>
        <textarea class="text" name="text"></textarea><br>
        <button type="submit">comment</button>
    </form>
    <br>
    <br>
    {% for comment in threaded %}
    <div style="margin-left: {{ comment.depth }}em">
        <div class="vote comment-date small">
        {% if user %}
            {% ifequal user comment.nickname %}
            <span class="comment-star">&#9733;</span>
            {% else %}
            <a href="/upvote/comm/{{ comment.id }}">&#9650;</a><!-- &#9660; -->
            {% endifequal %}
        {% else %}
            <span class="comment-star">&#9733;</span>
        {% endif %}
            <span class="comment-points">{{ comment.points }} point{{ comment.points|pluralize }}</span> by {{ comment.nickname }} {{ comment.date|timesince }} ago
        </div>
        <div class="comment-text">{{ comment.text|capfirst|linebreaksbr }}</div>
        <div class="comment-reply">
        {% if user %}
            {% ifequal user comment.nickname %}
            <a href="/comment/{{ comment.postid }}/{{ comment.parentid }}/{{ comment.depth }}/{{ comment.id }}">(edit)</a>
            -
            <a href="/comment/{{ comment.postid }}/{{ comment.parentid }}/{{ comment.depth }}/{{ comment.id }}/delete">(delete)</a> 
            {% else %}
            <a href="/comment/{{ comment.postid }}/{{ comment.id }}/{{ comment.depth|add:1 }}">reply</a> 
            {% endifequal %}
        {% else %}
            <a href="/comment/{{ comment.postid }}/{{ comment.id }}/{{ comment.depth|add:1 }}">reply</a> 
        {% endif %}
        </div>
        <br>
    </div>
    {% endfor %}
{% endblock %}